﻿#ifndef CAMERAVIEW_H
#define CAMERAVIEW_H

#include <QWidget>
#include <QDateTime>
#include <QCamera>
#include <QCameraImageCapture>
#include <QCameraInfo>
#include <QMediaService>
#include <QMediaRecorder>
#include <QScopedPointer>
#include "imagesettings.h"

namespace Ui {
class CameraView;
}

class CameraView : public QWidget
{
    Q_OBJECT

public:
    explicit CameraView(QWidget *parent = nullptr);
    ~CameraView();

    void closeEvent(QCloseEvent *event);
public slots:
    void captrueImage();
    void openCamera();
    void closeCamera();

signals:
    void fcaptrued(int id, const QString& filename);
    void icaptrued(int id, const QImage& image);
private slots:
    //摄像头相关
    void setCamera(const QCameraInfo &cameraInfo);
    void updateCameraState(QCamera::State);
    void displayCameraError();
    void updateLockStatus(QCamera::LockStatus, QCamera::LockChangeReason);
    void readyForCapture(bool ready);
    void displayCaptureError(int, QCameraImageCapture::Error, const QString &errorString);

    void on_cameraSetup_clicked();

    void on_exposure_valueChanged(int value);

    void on_openCamera_clicked();

    void on_closeCamera_clicked();

    void on_cameraList_currentIndexChanged(int index);

    void on_ActGrabImage_clicked();

private:
    Ui::CameraView *ui;

    QScopedPointer<QCamera> m_camera;
    QScopedPointer<QCameraImageCapture> m_imageCapture;
    QImageEncoderSettings m_imageSettings;
};

#endif // CAMERAVIEW_H
